### Example 3

library(phom)

sphere_points <- function(n, d) {
	points <- matrix(rnorm(n*d), nrow = n, ncol = d)
	L <- apply(points, MARGIN = 1,
		   FUN = function(x){sqrt(sum(x*x))})
	D <- diag(1 / L)
	U <- D %*% points
	U
}

n <- 1000
d <- 4
X <- as.matrix(sphere_points(n, d))

max_dim <- d - 1
max_f <- 0.9
landmark_set_size <- 40
maxmin_samples <- 1000

intervals <- pHom(X, max_dim, max_f, mode="lw", metric="euclidean", 
	landmark_set_size=landmark_set_size, maxmin_samples=maxmin_samples)


plotPersistenceDiagram(intervals, max_dim, max_f, 
	title="Random Points on S^3")
